﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using The_Chronicles_of_Asku.Areas.Tomb_Floors._1_10.ResourceFile;
using The_Chronicles_of_Asku.Characters;
namespace The_Chronicles_of_Asku.Areas.Tomb_Floors._1_10
{
    class FloorSix
    {
        Battle battle = new Battle();
        Skeleton skel = new Skeleton();
        Necromancer necro = new Necromancer();
        Undead zombie = new Undead();
        SetMobLevels setLevel = new SetMobLevels();
        Hero myHero = new Hero();
        Villager villager = new Villager();
        public bool complete = false;

        public void theFloor(Hero myHero, Mob mob)
        {
            setLevel.setMobLevelEleven(skel, necro, zombie, villager);

            Console.WriteLine(FloorSixText.Entrance);
            SkeletonFight(myHero, skel);
            SkeletonFight(myHero, skel);
            SkeletonFight(myHero, skel);

            if (myHero.isAlive == true)
            {
                string forkOne;
                do
                {
                    Console.WriteLine(FloorSixText.ForkInThePathOne);
                    forkOne = Console.ReadLine();
                    switch (forkOne)
                    {
                        case "1":
                            Console.WriteLine(FloorSixText.FirstLeft);
                            NecromancerFight(myHero, necro);
                            VillagerFight(myHero, villager);
                            NecromancerFight(myHero, necro);
                            VillagerFight(myHero, villager);
                            NecromancerFight(myHero, necro);
                            VillagerFight(myHero, villager);
                            break;

                        case "2":
                            Console.WriteLine(FloorSixText.FirstRight);
                            UndeadFight(myHero, zombie);
                            UndeadFight(myHero, zombie);
                            UndeadFight(myHero, zombie);
                            break;

                        default:
                            Console.WriteLine("You made the wrong decision you incompetent moron");
                            break;
                    }
                } while (forkOne != "1" && forkOne != "2" && myHero.isAlive == true);
            }

            setLevel.setMobLevelTwelve(skel, necro, zombie, villager);

            if (myHero.isAlive == true)
            {
                string forkTwo = "";

                do
                {
                    Console.WriteLine(FloorSixText.SecondFork);
                    forkTwo = Console.ReadLine();

                    switch (forkTwo)
                    {
                        case "1":
                            Console.WriteLine(FloorSixText.SecondFirst);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            SkeletonFight(myHero, skel);
                            break;

                        case "2":
                            Console.WriteLine(FloorSixText.SecondSecond);
                            VillagerFight(myHero, villager);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            NecromancerFight(myHero, necro);
                            break;

                        case "3":
                            Console.WriteLine(FloorSixText.SecondThird);
                            VillagerFight(myHero, villager);
                            VillagerFight(myHero, villager);
                            VillagerFight(myHero, villager);
                            VillagerFight(myHero, villager);
                            break;

                        default:
                            Console.WriteLine("You made the wrong decision you incompetent moron");
                            break;
                    }

                } while (forkTwo != "1" && forkTwo != "2" && forkTwo != "3" && myHero.isAlive == true);
            }

            if (myHero.isAlive == true)
            {
                string tunnelQuestion;
                
                    Console.WriteLine(FloorSixText.TunnelThird);
                    UndeadFight(myHero, zombie);
                    SkeletonFight(myHero, skel);
                    UndeadFight(myHero, zombie);
                    SkeletonFight(myHero, skel);
                    UndeadFight(myHero, zombie);

                    if (myHero.isAlive == true)
                    {
                        do
                        {
                            Console.WriteLine(FloorSixText.TwoDoorsAfterTunnel);
                            tunnelQuestion = Console.ReadLine();

                            switch (tunnelQuestion)
                            {
                                case "1":
                                    Console.WriteLine(FloorSixText.TunnelLeft);
                                    NecromancerFight(myHero, necro);
                                    NecromancerFight(myHero, necro);
                                    NecromancerFight(myHero, necro);
                                    break;

                                case "2":
                                    Console.WriteLine(FloorSixText.TunnelRight);
                                    SkeletonFight(myHero, skel);
                                    SkeletonFight(myHero, skel);
                                    SkeletonFight(myHero, skel);
                                    break;

                                default:
                                    Console.WriteLine("You made the wrong decision you incompetent moron");
                                    break;
                            }
                        } while (tunnelQuestion != "1" && tunnelQuestion != "2" && myHero.isAlive == true);
                    }
                    
            }

            if (myHero.isAlive == true)
            {
                Console.WriteLine(FloorSixText.End);
                ClearScreen();
                complete = true;
            }
            

            if (myHero.isAlive == false)
            {
                Console.WriteLine(FloorSixText.Dead);
                myHero.isAlive = true;
            }
        }

        private void UndeadFight(Hero myHero, Undead zombie)
        {
            if (myHero.isAlive == true)
            {
                battle.Fight(myHero, zombie);
                Console.ReadKey();
            }
            myHero.ResetStats(myHero);
            zombie.ResetStats(zombie);

            Console.Clear();
        }

        private void SkeletonFight(Hero myHero, Skeleton skel)
        {
            if (myHero.isAlive == true)
            {
                battle.Fight(myHero, skel);
                Console.ReadKey();
            }
            myHero.ResetStats(myHero);
            skel.ResetStats(skel);

            Console.Clear();
        }

        private void NecromancerFight(Hero myHero, Necromancer necro)
        {
            if (myHero.isAlive == true)
            {
                battle.Fight(myHero, necro);
                Console.ReadKey();
            }
            myHero.ResetStats(myHero);
            necro.ResetStats(necro);

            Console.Clear();
        }

        private void VillagerFight(Hero myHero, Villager villager)
        {
            if (myHero.isAlive == true)
            {
                battle.Fight(myHero, villager);
                Console.ReadKey();
            }
            myHero.ResetStats(myHero);
            villager.ResetStats(villager);

            Console.Clear();
        }

        private void ClearScreen()
        {
            Console.ReadKey();
            Console.Clear();
        }
    }
}
